package chapter10.p;

interface U {
	void f1();
	void f2();
	void f3();
}
class A1 {
	class B1 implements U {
		public void f1() {
		}
		public void f2() {
		}
		public void f3() {
		}

	}
	U makeU() {
		return new B1(){};
	}
}
class B2 {
	private U[] u;
	public void f1(int index ,U ui) {
		u[index] = ui;
	}
	public void f2(int index) {
		u[index] = null;
	}
	public void f3() {
		for (int i = 0; i < u.length ; i++) {
			u[i].f1();
			u[i].f2();
			u[i].f3();
		}
	}
}
public class P23 {
	public static void main(String[] args) {
		A1[] a1 = new A1[10];
		B2 b2 = new B2();
		for (int i = 0; i < a1.length ; i ++) {
			b2.f1(i, a1[i].makeU());
			b2.f3();
		}
		b2.f2(4);
		b2.f2(5);
		b2.f2(6);
		for (int i = 0; i < a1.length ; i ++) {
			b2.f1(i, a1[i].makeU());
			b2.f3();
		}
	}
}
